<template>
  <n-upload
      style="width: 100%;"
      multiple
      :action="actionUrl"
      @finish="handleFinish"
  >
    <n-upload-dragger style="width: calc(100vw - 252px); height: 20vh">
      <n-text style="font-size: 16px">
        点击或者拖动文件到该区域来上传
      </n-text>
    </n-upload-dragger>
  </n-upload>
</template>

<script>
import {axiosConfig} from "../utils/axios-instance";

export default {
  name: "image-pick",
  setup() {
    const actionUrl = axiosConfig.baseURL + "/images/easydl"

    const handleFinish = ({file, event}) => {
      if (event != null) {
        let data = JSON.parse(event.target.response)
        console.log(data)
        file.name = data.easyDlResult.easyDlResultId
        file.url = axiosConfig.baseURL + "/easyDlResults/" + data.easyDlResult.easyDlResultId
      } else {

      }
    }

    return{
      actionUrl,
      handleFinish
    }
  }
}
</script>

<style scoped>

</style>